home *** CD-ROM | disk | FTP | other *** search
- # Commands covered: lsearch
- #
- # This file contains a collection of tests for one or more of the Tcl
- # built-in commands. Sourcing this file into Tcl runs the tests and
- # generates output for errors. No output means no errors were found.
- #
- # Copyright 1991 Regents of the University of California
- # Permission to use, copy, modify, and distribute this
- # software and its documentation for any purpose and without
- # fee is hereby granted, provided that this copyright notice
- # appears in all copies. The University of California makes no
- # representations about the suitability of this software for any
- # purpose. It is provided "as is" without express or implied
- # warranty.
- #
- # $Header: /sprite/src/lib/tcl/tests/RCS/lsearch.test,v 1.1 91/08/21 13:37:25 ouster Exp $ (Berkeley)
-
- if {[string compare test [info procs test]] == 1} then {source defs}
-
- set x {abcd bbcd 123 234 345}
- test lsearch-1.1 {lsearch command} {
- lsearch $x 123
- } 2
- test lsearch-1.2 {lsearch command} {
- lsearch $x 3456
- } -1
- test lsearch-1.3 {lsearch command} {
- lsearch $x *5
- } 4
- test lsearch-1.4 {lsearch command} {
- lsearch $x *bc*
- } 0
-
- test lsearch-2.1 {lsearch errors} {
- list [catch lsearch msg] $msg
- } {1 {wrong # args: should be "lsearch list pattern"}}
- test lsearch-2.2 {lsearch errors} {
- list [catch {lsearch a} msg] $msg
- } {1 {wrong # args: should be "lsearch list pattern"}}
- test lsearch-2.3 {lsearch errors} {
- list [catch {lsearch a b c} msg] $msg
- } {1 {wrong # args: should be "lsearch list pattern"}}
- test lsearch-2.4 {lsearch errors} {
- list [catch {lsearch "\{" b} msg] $msg
- } {1 {unmatched open brace in list}}
-